	<table class="table table-hover">
	<tr>
		<td></td>
		<td><button type="button" class="btn btn-primary btn-lg" onClick="addOrModifyEmployeeJobType({{employeeid}},0)">_('add new jobtype')</button></td>
	</tr>
	{{#employeejobs}}
	<tr {{#employeejobtypeactive}}class="success"{{/employeejobtypeactive}} id="tablerow_employeejobtypeid_{{employeejobtypeid}}">
		<td {{#employeejobtypeactive}}class="success"{{/employeejobtypeactive}}>
			_('jobtypetitle')<b>{{jobtypetitle}}</b><br>
			_('from'):&nbsp;{{employeejobtypestartdate}}&nbsp;_('to'):{{employeejobtypeexpirationdate}}
		</td>
		<td>
			<button type="button" class="btn" onClick="addOrModifyEmployeeJobType({{employeeid}}, {{employeejobtypeid}})">_('more')</button>
		</td>
	</tr>
	{{/employeejobs}}
</table>
<div id="employeejobedit_dialog" title="_('employee job edit')">
</div>
<script>
function addOrModifyEmployeeJobType(employeeid, employeejobtypeid)
{
	console.log('addOrModifyJobType...');
	//createJobsMenu();
	var employeejob = {};
	// if employeejob is found that means we edit it. Otherwise we create a new one.
	for(i = 0; i < g_currentEmployee['employeejobs'].length; i++)
	{
		if(employeejobtypeid == g_currentEmployee['employeejobs'][i].employeejobtypeid)
		{
			employeejob = g_currentEmployee['employeejobs'][i];
			break;
		}
	}	
	if(!g_employeeJobsEditorTemplate)
	{
		$.get('/static/js/templates/employeejob_edit.html', function(template)
		{
			g_employeeJobsEditorTemplate = template; 
			var rendered = Mustache.render(template, employeejob);
			$('#employeejobedit_dialog').html(rendered)
			$('#employeejobedit_dialog').dialog({height: 400, width: 600, open: function(evenut, ui)
			{
			/* For existing employeejobtype we do not allow for existing jobtype to get changed.
			Only when you create new job type for an employee you can choose it for jobs_menu
			*/			  	
			if(employeejobtypeid == 0)
			{			  	
				console.log('employeejobtypeid =' + employeejobtypeid + ' thus we create menu');
			 	createJobsMenu();
			}
			}});
		}).fail(function(e){console.log(e);});
	}
	else
	{
		var rendered = Mustache.render(g_employeeJobsEditorTemplate, employeejob);
		$('#employeejobedit_dialog').html(rendered)
		$('#employeejobedit_dialog').dialog({height: 400, width: 600, open: function(evenut, ui)
		{
		/* For existing employeejobtype we do not allow for existing jobtype to get changed.
		Only when you create new job type for an employee you can choose it for jobs_menu
		*/			  	
			if(employeejobtypeid == 0)
			{			  	
				console.log('employeejobtypeid =' + employeejobtypeid + ' thus we create menu');
			 	createJobsMenu();
			}
			}
		});		
	}	
}
</script>